package nicg.st.service.generatereportservice;

import java.util.List;
import java.util.Stack;

import nicg.st.entity.Divate;
import nicg.st.entity.EvalResult;
import nicg.st.entity.IndicatorTree;

/**
 * 这个类产生夺控任务的评估报告
 * 
 * @author XXH
 *
 */
public class Report33 extends BaseReport {

	@Override
	public String produceSelfReport(EvalResult evalResult, IndicatorTree itNode, List<Divate> divateList) {
		// 下面对应我方区域失去，敌方区域攻占
		double ourAreaLoss = 0, enemyAreaOccupy = 0;
		// 下面对应临机处置下面的是否正确和是否及时
		double judgeRight = 0, judgeIntime = 0;
		// 下面对应合成营协同情况
		double ArmyCooperate = 0;
		// 下面对应战斗部署
		double fightArrange = 0;

		Stack<IndicatorTree> stack = new Stack<>();
		stack.push(itNode);
		while (!stack.isEmpty()) {
			IndicatorTree nowNode = stack.pop();
			if (nowNode.getName().equals("我方区域失去"))
				ourAreaLoss = nowNode.getValue2();
			if (nowNode.getName().equals("敌方区域攻占"))
				enemyAreaOccupy = nowNode.getValue2();
			if (nowNode.getName().equals("是否正确"))
				judgeRight = nowNode.getValue2();
			if (nowNode.getName().equals("是否及时"))
				judgeIntime = nowNode.getValue2();
			if (nowNode.getName().equals("合成营协同情况"))
				ArmyCooperate = nowNode.getValue2();
			if (nowNode.getName().equals("战斗部署"))
				fightArrange = nowNode.getValue2();

			List<IndicatorTree> children = nowNode.getChildren();
			if (children != null) {
				for (IndicatorTree child : children) {
					stack.push(child);
				}
			}
		}

		// 首先定义本指标体系的报告头
		String headReport = "由合成某旅合成4营配属防空营的地空导弹连HN-6地空导弹2个组，作战支援营的防化连喷火火箭排喷火"
				+ "班（欠1个组），陆航XX旅攻击直升机营1连编成，担任主攻任务，目标是消灭敌某部有生力量，夺取2013高程" + "点（06、33）。<br/>";

		// 从父接口中首先获取公共评估报告
		String[] commonReport = produceBaseReport(evalResult, itNode);

		// 首先对战损字符串去掉末尾的句号和换行，因为这里还要对战损进行补充
		commonReport[1] = commonReport[1].substring(0, commonReport[1].length() - 6);
		commonReport[1] += "，防守区域丢失情况" + numberString1[genrateString(ourAreaLoss)] + "。<br/>";
		// 首先对战果字符串去掉末尾的句号和换行，因为这里还要对战果进行补充
		commonReport[2] = commonReport[2].substring(0, commonReport[2].length() - 6);
		commonReport[2] += "，敌方防守区域被攻占" + numberString2[genrateString(enemyAreaOccupy)] + "。<br/>";
		// 夺控任务还有指挥相关的部分报告
		String directReport = "3.指挥<br/>我方指挥员临机指挥表现" + degreeString[genrateString((judgeRight + judgeIntime) / 2)]
				+ "，各分队部署展开情况" + degreeString[genrateString(fightArrange)] + "，协作作战行动完成"
				+ degreeString[genrateString(ArmyCooperate)] + "。<br/>";

		// 最后还有一个偏离的报告
		String divateReport = produceDivateReport(evalResult, divateList, 4);

		// 有了以上的报告，最后拼接成最终的报告
		String finalReport = headReport + commonReport[0] + commonReport[1] + commonReport[2] + directReport
				+ divateReport;

		return finalReport;
	}

}
